# Maintainer: Will Sinatra <wpsinatra@gmail.com>
# Contributor: Will Sinatra <wpsinatra@gmail.com>
pkgname=ruby-yard
_gemname=${pkgname#ruby-}
pkgver=0.9.37
pkgrel=0
pkgdesc="a documentation generation tool for Ruby"
url="https://rubygems.org/gems/yard"
arch="noarch"
license="MIT"
checkdepends="ruby-rake ruby-bundler ruby-test-unit ruby-test-unit-rr"
source="$pkgname-$pkgver.tar.gz::https://github.com/lsegal/yard/archive/refs/tags/v$pkgver.tar.gz"
subpackages="$pkgname-doc"
builddir="$srcdir/$_gemname-$pkgver"

prepare() {
	default_prepare

	sed -i '/spec.signing_key/d' $_gemname.gemspec
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rake
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install --local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname

	rm -r "$gemdir"/cache \
		"$gemdir"/build_info \
		"$gemdir"/doc

	mkdir -p "$pkgdir"/usr/share/doc/"$pkgname"/
	install -Dm644 "$builddir"/docs/*.md "$pkgdir"/usr/share/doc/"$pkgname"/

	cd "$gemdir/gems/$_gemname-$pkgver"
	rm -r README.md CHANGELOG.md LEGAL docs LICENSE

	install -Dm644 "$builddir"/LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
}

sha512sums="
f48a25df1fba7cdde7388842c6bce63ab149e613921cca8c809adb2a3bd7edce49c573c8867e62a3cb33c8cb3868dd67bd87f34c65ffce1e66c1353a2f93f9ca  ruby-yard-0.9.37.tar.gz
"
